package com.atom.module.document.utils;

import android.util.Size;

import com.atom.module.logger.Logger;

/**
 * All rights Reserved, Designed By www.rongdasoft.com
 *
 * @version V1.0
 * @Title: ListUtils
 * @Description:
 * @author: wuyongzheng
 * @date: 2022/3/25
 * @Copyright: 2022/3/25 www.rongdasoft.com Inc. All rights reserved.
 */
public interface SizeUtils {


    static float ratio(Size size) {
        return size.getHeight() / (float) size.getWidth();
    }

    static boolean isSixteenToNine(Size size) {
        return ratio(size) == 16 / 9f;
    }

    static boolean isFiveToThree(Size size) {
        return ratio(size) == 5 / 3f;
    }


    static boolean isFourToThree(Size size) {
        return ratio(size) == 4 / 3f;
    }


    static boolean isTwoToOne(Size size) {
        return ratio(size) == 2f;
    }

    static boolean isThreeToFour(Size size) {
        Logger.e("isThreeToFour  %s , %s " ,size.toString() , ratio(size));
        return ratio(size) == 3 / 4f;
    }


    static boolean isThreeToTwo(Size size) {
        return ratio(size) == 3 / 2f;
    }

    static boolean isSixToFive(Size size) {
        return ratio(size) == 6 / 5f;
    }

    static boolean isNineteenToNine(Size size) {
        return ratio(size) == 19 / 9f;
    }

    static boolean isNineteenToEight(Size size) {
        return ratio(size) == 19 / 8f;
    }


    static boolean isOneNineToOne(Size size) {
        return ratio(size) == 1.9f;
    }


    static boolean isSquare(Size size) {
        return size.getWidth() == size.getHeight();
    }

    static String getAspectRatio(Size size) {
        if (isSixteenToNine(size)) return "16:9";
        if (isFiveToThree(size)) return "5:3";
        if (isFourToThree(size)) return "4:3";
        if (isThreeToFour(size)) return "3:4";
        if (isThreeToTwo(size)) return "3:2";
        if (isSixToFive(size)) return "6:5";
        if (isOneNineToOne(size)) return "1.9:1";
        if (isNineteenToNine(size)) return "19:9";
        if (isNineteenToEight(size)) return "19:8";
        if (isSquare(size)) return "1:1";
        if (isTwoToOne(size)) return "2:1";
        return "other";
    }
}
